import { Module } from '@nestjs/common'
import { RedisService } from './redis.service'
import { createClient } from 'redis'
import { RedisController } from './redis.controller'

@Module({
   providers: [
      RedisService,
      {
         provide: 'REDIS_CLIENT',
         async useFactory() {
            const client = createClient({
               socket: {
                  host: 'localhost',
                  port: 6379
               }
            })
            await client.connect()
            return client
         }
      }   
   ],
   exports: [RedisService],
   controllers: [RedisController]
})
export class RedisModule {}
